package cn.itcast.web.controller.stat;

import cn.itcast.service.stat.StatService;
import cn.itcast.web.controller.BaseController;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/stat")
public class StatController extends BaseController {

    @Reference
    private StatService statService;

    /**
     * 进入到统计分析页面
     *  参数：
     *      chartsType ：图标类型
     *          factory：工厂
     *          online：在线人数
     *          sell：销量
     */
    @RequestMapping("/toCharts")
    public String toCharts(String chartsType) {
        return "stat/stat-"+chartsType;
    }


    /**
     * 接受ajax请求，调用service获取对应厂家统计数据
     */
    @RequestMapping("/getFactoryData")
    @ResponseBody
    public List<Map> getFactoryData() {
        return statService.getFactoryData(getLoginCompanyId());
    }

    /**
     * 获取销售统计排行榜数据
     */
    @RequestMapping("/getSellData")
    @ResponseBody
    public List<Map> getSellData() {
        return statService.getSellData(getLoginCompanyId());
    }

    /**
     * 获取系统访问压力图数据
     */
    @RequestMapping("/getOnlineData")
    @ResponseBody
    public List<Map> getOnlineData() {
        return statService.getOnlineData(getLoginCompanyId());
    }
}
